package com.yuyou.train.user.service.impl;

import java.util.Date;
import java.util.List;

import com.yuyou.train.user.vo.resp.RespUserRaiseTop;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yuyou.train.service.api.user.entity.UserPraise;
import com.yuyou.train.user.mapper.UserPraiseMapper;
import com.yuyou.train.user.service.IUserPraiseService;
import com.yuyou.train.util.tool.Sequence;
import com.yuyou.train.util.tool.UUIDUtil;

@Service
public class UserPraiseServiceImpl implements IUserPraiseService{

	@Autowired
	private UserPraiseMapper userPraiseMapper;
	
	@Override
	public int deleteByPrimaryKey(String id) {
		return userPraiseMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(UserPraise record) {
		record.setId(Sequence.getSequence().getNextId());
		record.setCreateTime(new Date());
		record.setPoints(1);
		return userPraiseMapper.insert(record);
	}

	@Override
	public UserPraise selectByPrimaryKey(String id) {
		return userPraiseMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(UserPraise record) {
		return userPraiseMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public List<UserPraise> findUserPraiseByForeignId(String foreignId) {
		return userPraiseMapper.findUserPraiseByForeignId(foreignId);
	}

	@Override
	public UserPraise findPraiseByForeignIdAndUserId(String foreignId, String userId) {
		return userPraiseMapper.findPraiseByForeignIdAndUserId(foreignId, userId);
	}

	@Override
	public int deleteByfForeignIdUserId(String foreignId, String userId) {
		return userPraiseMapper.deleteByfForeignIdUserId(foreignId, userId);
	}

	@Override
	public Long sumByForeignId(String foreignId, String isPraise) {
		return userPraiseMapper.sumByForeignId(foreignId, isPraise);
	}

	@Override
	public List<RespUserRaiseTop> findHwPraiseTop(String classId, String isPraise) {
		return userPraiseMapper.findHwPraiseTop(classId, isPraise);
	}

	@Override
	public UserPraise selectUserPraise(String foreignId, String userId,
			String resourceType, String isPraise) {
		return userPraiseMapper.selectUserPraise(foreignId, userId, resourceType, isPraise);
	}

}